<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/jquery/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="js/ol.css">
    <script src="js/ol-debug.js"></script>
    <style>
        #popup {
            width: 20px;
            height: 20px;

            background-color: #0FF;
            opacity: 0.5;
        }
        #vienna {
            text-decoration: none;
            color: white;
            font-size: 11pt;
            font-weight: bold;
            text-shadow: black 0.1em 0.1em 0.2em;
        }
        .popover-content {
            min-width: 180px;
        }
    </style>

</head>
<body>
<div id="popup" title="Welcome to OpenLayers">asdf</div>
<div id="map" style="width: 100%"></div>
<script>
    var coordinate=[116,40];
    var point =new ol.geom.Point(coordinate);
    var point2=point.transform("EPSG:4326","EPSG:3857");

    var feature = new ol.Feature({
        geometry: point2
    });
    var vectorsource=new ol.source.Vector({
        features:[feature]
    });
    var vectorlayer=new ol.layer.Vector({
        source:vectorsource,
        style: new ol.style.Style({
            image: new ol.style.Circle({
                fill: new ol.style.Fill({
                    color: 'rgba(255,255,255,0.4)'
                }),
                stroke: new ol.style.Stroke({
                    color: '#3399CC',
                    width: 1.25
                }),
                radius: 5
            }),
            fill: new ol.style.Fill({
                color: 'rgba(255,255,255,0.4)'
            }),
            stroke: new ol.style.Stroke({
                color: '#3399CC',
                width: 1.25
            })
        })
    });


    //view
    var view=new ol.View({
        // 设置成都为地图中心
        center: ol.proj.transform([110,39],"EPSG:4326","EPSG:3857"),
        zoom: 4
    });
    var osm=new ol.layer.Tile({source: new ol.source.OSM()});
    // map
    var map = new ol.Map({
        layers: [
            getTdtLayer("vec_w"),
            getTdtLayer("cva_w"),
            vectorlayer
        ],
        view:view,
        target: 'map'
    });

    function getTdtLayer(lyr) {
        var urls=[];
        for(var i=0;i<8;i++)
        {
            urls.push( "http://t"+i+".tianditu.com/DataServer?T=" + lyr + "&X={x}&Y={y}&L={z}")
        }
        var layer = new ol.layer.Tile({
            source: new ol.source.XYZ({
                urls:urls
            })
        });
        return layer;
    }

    var popup = new ol.Overlay({
        element: document.getElementById('popup')
    });
    popup.setPosition(point2.getCoordinates());
    map.addOverlay(popup);




</script>
</body>
</html>